package peer.tools;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class IpChecker {
	public static void main(String[] args) throws UnknownHostException{
		InetAddress ip=InetAddress.getByName("172.18.199.55");
		System.out.println(isPubIp(ip));
	}
	public static boolean isPubIp(InetAddress ip){
		boolean is=true;
		String ips=ip.toString();
		int index1=ips.indexOf(".");
		int index2=ips.indexOf(".",index1+1);
		//int index3=ips.indexOf(".",index2+1);
		String a=ips.substring(1,index1);
		String b=ips.substring(index1+1,index2);
		//String c=ips.substring(index2+1,index3);
		//String d=ips.substring(index3+1);
		//System.out.println("RRRRRRRRR"+a+"#"+b+"#"+c+"#"+d+"#"+"TTTTT "+index1);
		if(a.equals("10")|a.equals("127")){
			is=false;
		}
		if(a.equals("192")&b.equals("168")){
			is=false;
		}
		if(a.equals("172")){
			int n=Integer.parseInt(b);
			if(n>=16&n<=31){
				is=false;
			}
		}
		return is;
	}

}
